package com.borzaindustries.mkdummy;

import java.util.*;

public class Randomizer {
	private Randomizer() {
		random = new Random();
	}

	private Random random;
	private static Randomizer instance;

	public static Randomizer getInstance() {
		if (instance == null)
			instance = new Randomizer();
		return instance;
	}

	public int getRandomNumber(int min, int max) {
		return random.nextInt(max - min) + min;
	}
	
	public String getShortRandomString(){
		return getRandomString(random.nextInt(9)+2);
	}

	public String getRandomString(int length) {
		StringBuilder b = new StringBuilder();
		for (int i = 0; i < length; i++) {
			b.append(getRandomChar());
		}
		return b.toString();
	}
	
	public void fillByteArray(byte[] buffer){		
		random.nextBytes(buffer);
	}

	private char getRandomChar() {
		// TODO Auto-generated method stub
		return (char) getRandomNumber(97/*a*/, 122+1/*z*/);// a=97 z=122+1
	}
}